package Engine.Blocks;

import static org.lwjgl.opengl.GL11.*;

import org.newdawn.slick.Color;
import org.newdawn.slick.opengl.Texture;

import Engine.PhysicEngine.RigidBody;

public abstract class DefaultBlock {

	public float PhysicType = 0;

	float UV_X1 = 0;
	float UV_Y1 = 0;
	float UV_X2 = 1f / 16.0f;
	float UV_Y2 = 1f / 16.0f;
	Texture texture;
	public int zindex = 0;

	public abstract int ID();

	public abstract void OnCollision(RigidBody rigidbody);

	public abstract void Draw(DrawInfos drawinfos, float XPosition,
			float YPosition);
	protected void DrawTextured(float Xpos, float Ypos, Texture texture) {
		DrawTextured(Xpos, Ypos, texture, Color.white);
	}

	protected void DrawTextured(float Xpos, float Ypos, Texture texture, Color color) {

		int Width = 16;
		int Height = 16;
		Xpos *= 16;
		Ypos *= 16;
		texture.bind();

		glPushMatrix();
		{

			glTranslatef(Xpos, Ypos, zindex);
			glBegin(GL_QUADS);
			{
				glColor4f(color.r, color.g, color.b, color.a);
				glTexCoord2f(UV_X1, UV_Y1);
				glVertex2f(0, 0);

				glColor4f(color.r, color.g, color.b, color.a);
				glTexCoord2f(UV_X2, UV_Y1);
				glVertex2f(Width, 0);

				glColor4f(color.r, color.g, color.b, color.a);
				glTexCoord2f(UV_X2, UV_Y2);
				glVertex2f(Width, Height);

				glColor4f(color.r, color.g, color.b, color.a);
				glTexCoord2f(UV_X1, UV_Y2);
				glVertex2f(0, Height);
			}
			glEnd();
		}
		glPopMatrix();
	}
}
